import Vue from 'vue'
import Index from './index.vue'

let messageInstance = null;
let MessageConstructor = Vue.extend(Index);

let init = () => {
  messageInstance = new MessageConstructor();
  messageInstance.$mount();

  document.body.appendChild(messageInstance.$el);
}

let caller = (options) => {
  if(!messageInstance) {
    init(options)
  }
  messageInstance.add(options)
}

export default {
  install(vue) {
    vue.prototype.$_message = caller
  }
}